import {BASE_URL} from '@/services/api'
import {METHOD, request} from '@/utils/request'

export async function queryRole(payload) {
  return request(`${BASE_URL}/sysRole/querySysRole`, METHOD.GET, payload)
}

export async function addRole(payload) {
  return request(`${BASE_URL}/sysRole/addSysRole`, METHOD.POST, payload)
}

export async function updateRole(payload) {
  let {objectId} = payload
  return request(`${BASE_URL}/sysRole/updateSysRole/${objectId}`, METHOD.PATCH, payload)
}

export async function deleteRole(payload) {
  return request(`${BASE_URL}/sysRole/deleteSysRole/${payload}`, METHOD.DELETE)
}

export async function saveMenu(payload) {
  return request(`${BASE_URL}/sysRoleMenu/addSysRoleMenu`, METHOD.POST, payload)
}

export async function queryMenuJson(payload) {
  return request(`${BASE_URL}/sysRoleMenu/querySysRoleMenuById`, METHOD.GET, payload)
}

export async function updateMenu(payload) {
  let {roleId} = payload
  return request(`${BASE_URL}/sysRoleMenu/updateSysRoleMenu/${roleId}`, METHOD.PATCH, payload)
}